package com.example.blog.module.controller;


import com.example.blog.module.entity.VO.CommentParam;
import com.example.blog.module.entity.VO.Result;
import com.example.blog.module.service.CommentService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zjx
 * @since 2022-12-27
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/comment")
public class CommentController {

    /**
     * 问题
     * 雪花算法生成LongId
     * 时间转换
     */

    private final CommentService commentService;

    @GetMapping("article/{id}")
    public Result comments(@PathVariable("id") Long articleId){
        return commentService.commentsByArticleId(articleId);
    }

    @PostMapping("create/change")
    public Result comment(@RequestBody CommentParam commentParam){
        return commentService.comment(commentParam);
    }

}

